/*
 * Filter This 0.2.3 jQuery Plugin
 * 
 * Copyright 2011, Andrei Olaru
 * All rights reserved.
 *
 * You need to purchase a license if you want to use this script on your website.
 * 
 */
 
$(document).ready(function() {

	/* Max filter elements */
	
	var max = $("ul#portfolio li").size();
	
	$("#filter-items").text(max);
	
	$("#filter-max").text(max);
	
	/* Tag filter */
	
	$('.greybox a').click(function() {
	
		var count = 0;
	
		$(this).css('outline','none');
		
		$('.greybox .current').removeClass('current');
		
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'reset') {
			
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
			
			$("#filter-items").text(max);
		
		}
	
		else {
			
			$('ul#portfolio li').each(function() {
			
				if(!$(this).hasClass(filterVal)) {
					
					$(this).fadeOut('slow').addClass('hidden');

				} 
				
				else {
					
					$(this).fadeIn('slow').removeClass('hidden');
					
					count++;

				}
			});
			
			$("#filter-items").text(count);
		}
		
		return false;
		
	});

	/* Search Filter 
	
	$("#filters").keyup(function () {
        
		var filter = $(this).val();
		
		var count = 0;
        
		$("ul#portofolio li").each(function () {
		
            if ($(this).text().search(new RegExp(filter, "i")) < 0) {
                
				$(this).addClass("hidden");
				
				$("#filter-items").text(max);
				
            } else {
                
				$(this).removeClass("hidden");
                
				count++;
				
            }
			
        });
		
        $("#filter-items").text(count);
		
    });*/
	
});